package com.ssy.lingxi.purchase.entity.bidding;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ssy.lingxi.purchase.api.dto.request.EnclosureUrlsRequest;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToEnclosureUrlsRequestListConverter;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToStringListConverter;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

/**
 * 采购询价货品实体类
 * @author wrc
 * @date 2021/1/19
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "pu_bidding_product")
public class BiddingProduct {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE,generator="bidding_product_seq")
    @SequenceGenerator(sequenceName="pu_bidding_product_seq", name="bidding_product_seq",allocationSize = 1)
    private Long id;

    /**
     *采购竞价单
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name="biddingId",referencedColumnName = "id")
    private Bidding  bidding;

    /**
     *物料规格型号
     */
    private String model;

    /**
     *物料编号
     */
    private String number;

    /**
     * 货号Id
     */
    private Long goodsId;

    /**
     * 物料名字
     */
    private String name;

    /**
     * 品类
     */
    private String category;

    /**
     * 品类集合
     */
    @Convert(converter = JpaJsonToStringListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<String> ids;

    /**
     * 物料属性
     */
    private String productAttributeJson;

    /**
     *采购单位
     */
    private String unit;

    /**
     *采购数量
     */
    private Double purchaseCount;

    /**
     *物料品牌
     */
    private String brand;

    /**
     * 附件
     */
    @Convert(converter = JpaJsonToEnclosureUrlsRequestListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<EnclosureUrlsRequest> urls;

    /**
     *货号
     */
    private String itemNo;
}
